package tech.aistar.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import tech.aistar.dto.MyWrongfirst;
import tech.aistar.entity.Collect;
import tech.aistar.entity.User;

import java.util.List;
@Repository
public interface UserMapper {
    @Select("select * from user where us_nickname='${username}'")
    User findUserBynickname(@Param("username")String username);

    @Insert("insert into user(us_nickname,us_password,us_phone) value (#{usNickname},#{usPassword},#{usPhone})")
    int insertUser(User user);

    @Update("update user set us_name = #{usName},us_nickname = #{usNickname},us_sex=#{usSex},us_phone=#{usPhone},us_password=#{usPassword}, us_birthday = #{usBirthday}, us_education = #{usEducation}, us_school=#{usSchool}, us_adress = #{usAdress} where us_id = #{usId}")
    int updateUser(User user);

    @Select("select * from user where us_id = ${uid}")
    User findUserById(Long uid);

    @Select("select * from wrongtopic where wrong_uid = ${uid}")
    List<MyWrongfirst> fingByUid(Long uid);

    @Select("select * from collect where col_id = ${uid}")
    List<Collect> fingByColId(Long uid);


}
